package 字符串.easy;

/**
 * @author Lw中
 * @date 2020/8/25 10:07
 */
public class LuWuQi {

    public static boolean judgeCircle(String moves) {
        // n，m分别代表y轴与x轴
        int n = 0, m = 0;
        for (int i = 0; i < moves.length(); i++) {
            if (moves.charAt(i) == 'L') {
                m++;
            }
            if (moves.charAt(i) == 'U') {
                n++;
            }
            if (moves.charAt(i) == 'R') {
                m--;
            }
            if (moves.charAt(i) == 'D') {
                n--;
            }
        }
        return n == 0 && m == 0;
    }

    public static void main(String[] args) {
        boolean udrl = judgeCircle("LDRRLRUULR");
        System.out.println(udrl);
    }

}
